﻿using System;
using System.Windows;
using nRoute.ViewServices.Contracts;
using nRoute.Components.Composition;

namespace nRoute.ViewServices.Services
{
    [MapViewService(typeof(IShowErrorViewService), ShowErrorViewService.SERVICE_NAME,
         InitializationMode = InitializationMode.OnDemand, Lifetime = ViewServiceLifetime.PerInstance)]
    public class ShowErrorViewService
		 : IShowErrorViewService
    {
        private const string SERVICE_NAME = "nRouteShowErrorViewService";

#region IShowErrorService Members

        public string Title { get; set; }

        public string ErrorMessage { get; set; }

        public Exception Error { get; set; }

        public void ShowError()
        {
            if (string.IsNullOrEmpty(Title))
            {
                MessageBox.Show(ErrorMessage);
            }
            else
            {
                MessageBox.Show(ErrorMessage, Title, MessageBoxButton.OK);
            }
        }

#endregion

    }
}
